<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.java.service.*,java.util.*,com.java.model.UserSession,com.java.util.*"%>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<jsp:include page="common/header.jsp"></jsp:include>
<%
	UserSession usersession = (UserSession)session.getAttribute("user");

	String connGroup 	= "";
	String user_id 		= "";
	if(usersession!=null){
		connGroup 	= CmmUtil.nvl(usersession.getConnGroup(),"0");
		user_id 	= CmmUtil.nvl(usersession.getUser_id(),"");
	}
	String keyword_gb 	= CmmUtil.nvl(request.getParameter("search_gb"),"");
	String keyword 		= CmmUtil.nvl(request.getParameter("search_word"),"");
	String line_number	= CmmUtil.nvl(request.getParameter("line_number"),"10");

	//페이징 처리 Start
 	//페이지 표시정보 받기 혹은 검색입력창
 	String curr_page = request.getParameter("curr_page");
 	if (curr_page == null || curr_page.equals(""))
 		curr_page = "1";
 	String one_page = request.getParameter("line_number");
 	if (one_page == null || one_page.equals(""))
 		one_page = "10";
 	String one_group = request.getParameter("one_group");
 	if (one_group == null || one_group.equals(""))
 		one_group = "10";
 	
 	String total_count = CmmUtil.nvl(request.getParameter("total_count"),"0");
 	
 	//페이징 처리 End
 	
	HashMap map = new HashMap();
	ArrayList list = new ArrayList();
	CommonDaoService commonservice = new CommonDaoService("Com0102lp01Dao");
	map.put("connGroup",connGroup);
	map.put("user_id",user_id);
	map.put("search_combo",keyword_gb);
	map.put("keyword",keyword);
	map.put("page_row",line_number);
	map.put("total_row",total_count);
	map.put("page_no",curr_page);
	
	list = (ArrayList)commonservice.commonDaoMethod(map);
	System.out.println(list);
	if(list != null){
		if(list.size() > 0){
			total_count = (String)((HashMap)list.get(0)).get("total_row");
			System.out.println("total_count ========> " + total_count);
		}
	}
	
	if(list.size() == 0){
		total_count = "0";
	}
	//화면에 뿌릴 값
	String cancel_yn = "";//상태
	
	//update로 넘길 값
	String poi_cd 		= "";
	String kisu_id 		= "";
	String ent_id 		= "";
	String member_id 	= "";
	String app_chk 		= "";
	String cancel_chk 	= "";
	String std_status	= "";
	String r_num="";
%>
<script>
//검색
function search(){
	var frm = document.mainfrm;
	frm.curr_page.value ="1";
	frm.total_count.value=0;
	frm.action = "/jsp/com0102l_p01.jsp";
	frm.target="_self";
	frm.submit();
}

// 페이지 번호를 눌렸을때.
function go_page(page){
	var frm = document.mainfrm;
	frm.curr_page.value = page ;			
	frm.total_count.value = "<%=total_count%>";
	frm.search_word.value = "<%=keyword%>";
	frm.action = "/jsp/com0102l_p01.jsp";
	frm.target="_self";
	frm.submit();
}

//일괄등록
function batch_reg(){
	var frm = document.mainfrm;
	open("","viewPop","width=620,height=185,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no ");
	frm.action = "/jsp/pop/com0102l_p01_pop01.jsp";
	frm.target = "viewPop";
	frm.method = "post";
	frm.submit();
}

//승인
function update(){
	var frm = document.mainfrm;
	frm.action = "/jsp/com0102l_p01_update.jsp";
	frm.target ="hide_src";
	frm.submit();
}
//전체 승인 선택
function all_check(){
	var frm = document.mainfrm;
	var cnt =document.getElementsByName("checkbox").length;
	for(var i=0; i<cnt; i++){
		document.getElementsByName("checkbox")[i].checked=true;
	}
}

//전체 취소 선택
function all_disable_check(){
	var frm = document.mainfrm;
	var cnt =document.getElementsByName("checkbox").length;
	for(var i=0; i<cnt; i++){
		document.getElementsByName("checkbox")[i].checked=false;
	}
}

//엑셀다운로드
function excel_down(){
	var frm = document.mainfrm;
	frm.action = "/jsp/com0102l_p01_excel.jsp";
	frm.target="_blank";
	frm.method = "post";
	frm.submit();	
}

//엔터키 
function checkkeycode(t){
	if ( event.keyCode == 13 ) {
		search();
	} 
}
</script>
<body>
<table width="992" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td>
    <!--top -->
		<jsp:include page="common/top_menu.jsp"></jsp:include>
    <!-- //top -->
    <!-- contents area -->
<form name="mainfrm" method="post">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
	
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="180" valign="top">
 		<jsp:include page="left/com0101l_p05.jsp"></jsp:include>
    </td>
    <td width="21" valign="top">&nbsp;</td>
    <td valign="top">
    	 <table width="790px"  border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td style="font-size:14px; color:#3b70a2; font-weight:bold; border-bottom:2px solid #c8c8c8; padding:0 0 5px 0;" align="left"><img src="/images/sub_icon1.jpg"  alt="" border="0">&nbsp;학습관리 - 수강신청관리</td>
             </tr>
        </table>
         <table width="790px" border="0" cellpadding="0" cellspacing="0" style="margin:20px 0 0 0">
           <tr>
             <td align="left">
             	<jsp:include page="common/selectbox_list.jsp"></jsp:include> 
             </td>

             <td align="right"><img src="/images/icon_search.gif" align="absmiddle" />&nbsp;검색&nbsp;&nbsp;
             
             	<select name="search_gb">
                 <option value="" <%if(keyword_gb.equals("")){%>selected<%}%>>검색조건</option>
                 <option value="1" <%if(keyword_gb.equals("1")){%>selected<%}%>>성명</option>
                 <option value="2" <%if(keyword_gb.equals("2")){%>selected<%}%>>과정명</option>
               </select>
           		<input type="text" name="search_word" value="<%=keyword %>" onKeypress="checkkeycode(event);" class="textbox" required="required" hname="검색어" />
                <a href="javascript:search()"><img src="/images/bt_search2.gif" align=absmiddle /></a>
             </td>
           </tr>
         </table>
         <table width="790px" border="0" cellspacing="0" class="bbs_property" summary="" style="font-size:11px; margin:13px 0 20px 0;">
            <caption></caption>
            <thead>
             <tr>
              <th>No</th>
              <th>과정</th>
              <th>성명</th>
              <th>수강기간</th>
              <th>신청일자</th>
              <th>상태</th>
              <th>비고</th>
              <th>체크</th>
             </tr>
            </thead>
            <tbody>
            <%if(list != null && list.size() > 0){%>
			<%for(int i=0; i<list.size(); i++){
            	HashMap map1 = (HashMap)list.get(i);
            	
            	/*java.util.regex.Pattern p = java.util.regex.Pattern.compile("(</*\\w*>)|(<.+//)|(\">.+)");
            	String imsi = (String)map1.get("std_status");
            	
            	Matcher m = p.matcher(imsi);
            	System.out.println(m.toMatchResult());*/
            	
            	
            	std_status	= CmmUtil.nvl((String)map1.get("std_status"),"");
            	poi_cd 		= CmmUtil.nvl((String)map1.get("poi_cd"),"");
            	kisu_id 	= CmmUtil.nvl((String)map1.get("kisu_id"),"");
            	ent_id 		= CmmUtil.nvl((String)map1.get("ent_id"),"");
            	member_id 	= CmmUtil.nvl((String)map1.get("member_id"),"");
            	app_chk 	= CmmUtil.nvl((String)map1.get("approval_yn"),"");
            	cancel_chk 	= CmmUtil.nvl((String)map1.get("cancel_yn"),"");
            	
            	r_num			= CmmUtil.nvl((String)map1.get("r_num") ,"");
			%>
			
	<!-- 수강신청(update)로 넘길 인자 -->
<input type="hidden" name="poi_cd" value="<%=poi_cd%>">
<input type="hidden" name="kisu_id" value="<%=kisu_id%>">
<input type="hidden" name="ent_id" value="<%=ent_id%>">
<input type="hidden" name="member_id" value="<%=member_id%>">
<input type="hidden" name="app_chk" value="1">
<input type="hidden" name="cancel_chk" value="0">
<input type="hidden" name="user_id" value="<%=user_id%>">
	<!-- //수강신청(update)로 넘길 인자 -->

             <tr>
              <td scope="row" class="ranking"><%=r_num %></td>
              <td align="left"><%=map1.get("poi_nm") %></td>
              <td><%=map1.get("login_nm")%></td>
              <td><%=map1.get("std_app_dt")%></td>
              <td><%=map1.get("app_dt")%></td>
              <td><%=std_status%></td>
              <td><%=map1.get("repl_dt")%></td>
              <td><input type="checkbox" name = "checkbox" id="checkbox" onclick="" value="<%=i%>"></td>
             </tr>
             <%} %>
            <%}else{ %>
             <tr>
             	<td colspan="8">데이터가 없습니다</td>
             </tr>
            <%} %>
            </tbody>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
             <tr>
  
                <td align="right">
                	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <!-- 페이징 -->
                       <div class="pagelist"><common:pagelistnew currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=one_page%>" oneGroup="<%=one_group%>"/></div>
                        <!-- //페이징 -->
                      </tr>
                    </table>
           	  		<table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="84px" align="left">
                            <table border="0" cellpadding="0" cellspacing="0" >
                                <tr>
                                  <!--  td><a href="javascript:batch_reg()"><img src="/images/btn_up.gif" align="absmiddle" /></a></td -->
                                   <td align="left" style="padding:0 0 0 3px;">
                                   	<a href="javascript:excel_down()">
                                   		<img src="/images/btn_save_excel2.gif" align="absmiddle" />
                                   	</a>
                                   	</td>
                                </tr>
                            </table>
                         </td>
                        <td align="right">
                        	<table border="0" cellpadding="0" cellspacing="0" >
                                <tr>
                                  <td><input name="button" type="button" class="btn_gray_blue1"  value="전체승인선택" onClick="javascript:all_check()" /></td>
                                  <td align="left" style="padding:0 0 0 3px;"><input name="button3" type="button" class="btn_gray_blue1"  value="전체취소선택" onclick="javascript:all_disable_check()"/></td>
                                  <td align="left" style="padding:0 0 0 3px;"><input name="button3" type="button" class="btn_gray_blue2"  value="승인" onclick="javascript:update();"/></td>
                                </tr>
                            </table>
                        </td>
                        </tr>
                    </table> 
               </td>
             </tr>
           </table>
    </td>
    </tr>
	</table>
</form>
    	<jsp:include page="common/footer.jsp"></jsp:include>
	</td>
  </tr>
</table>
<iframe name='hide_src'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
</body>
</html>
